<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex align-stretch benben-position-layout flex hosList_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex align-center justify-between flex-sub hosList_fd0_0'>
          <view class='flex align-center' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
            <text class='fu-iconfont2  hosList_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex align-center flex-sub hosList_fd0_0_c1'>
            <text class='fu-iconfont2  hosList_fd0_0_c1_c0' @tap.stop="topSearchFunc()">&#xe738;</text>
            <benben-input class='flex-sub hosList_fd0_0_c1_c1' type="text" :placeholder="$t('请输入商品名称')"
              confirm-type="done" :maxlength="-1" placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx"
              @confirm="topSearchFunc()" v-model="keyword" />
            <image class='hosList_fd0_0_c1_c2' mode="aspectFit" :src='STATIC_URL+"236.png"'
              @tap.stop="cleanKeywordFunc()" v-if="keyword!=''"></image>
          </view>
          <view class='flex flex-wrap align-center hosList_fd0_0_c2' v-if=" appSystemIdentification=='Wechat'">
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <view class="flex flex-direction align-stretch justify-center benben-position-layout flex hosList_flex_1"
        :style="{top:(87+StatusBarRpx)+'rpx', }">
        <view class='flex align-center self-center flex-sub hosList_fd1_0'>
          <view class='flex align-center hosList_fd1_0_c0' @tap.stop="switchComprehensiveFunc()">
            <text class='hosList_fd1_0_c0_c0' v-if="sort_field!='1'">{{$t('综合')}}</text><text
              class='hosList_fd1_0_c0_c0_1' v-if="sort_field=='1'">{{$t('综合')}}</text>
          </view>
          <view class='flex align-center hosList_fd1_0_c1' @tap.stop="switchShopListFunc(2)" v-if="showId=='1'">
            <text class='hosList_fd1_0_c1_c0' v-if="sort_field!='2'">{{$t('销量')}}</text><text
              class='hosList_fd1_0_c1_c0_1' v-if="sort_field=='2'">{{$t('销量')}}</text>
            <image class='hosList_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"237.png"' v-if="sort_field!='2'">
            </image>
            <image class='hosList_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"27.png"'
              v-if="sort_field=='2' && sort_type=='desc'"></image>
            <image class='hosList_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"26.png"'
              v-if="sort_field=='2' && sort_type=='asc'"></image>
          </view>
          <view class='flex align-center hosList_fd1_0_c2' @tap.stop="switchShopListFunc(3)" v-if="showId=='1'">
            <text class='hosList_fd1_0_c1_c0' v-if="sort_field!='3'">{{$t('价格')}}</text><text
              class='hosList_fd1_0_c2_c0_1' v-if="sort_field=='3'">{{$t('价格')}}</text>
            <image class='hosList_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"237.png"' v-if="sort_field!='3'">
            </image>
            <image class='hosList_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"27.png"'
              v-if="sort_field=='3' && sort_type=='desc'"></image>
            <image class='hosList_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"26.png"'
              v-if="sort_field=='3' && sort_type=='asc'"></image>
          </view>
          <view class='flex align-center hosList_fd1_0_c3' v-if="showId=='1'">
            <image class='hosList_fd1_0_c3_c0' mode="aspectFit" :src='STATIC_URL+"238.png"' @tap.stop="switchcutFunc(2)"
              v-if="cutId=='1'"></image>
            <image class='hosList_fd1_0_c3_c0' mode="aspectFit" :src='STATIC_URL+"239.png"' @tap.stop="switchcutFunc(1)"
              v-if="cutId=='2'"></image>
          </view>
        </view>

      </view>
      <view :style="{height: '100rpx'}"></view>
      <!---商品列表_商品flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout hosList_flex_2"
        v-if="cutId=='1' && showId=='1'">
        <template v-for='(item,key0) in goods_List'>
          <view class='flex align-center hosList_fd2_0' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/fl/shopDetail/shopDetail?id=${item.aid}`" :key='key0'>
            <image class='hosList_fd2_0_c0' mode="aspectFill" :src='item.thumb'></image>
            <view class='flex flex-direction flex-wrap align-stretch flex-sub hosList_fd2_0_c1'>
              <text class='hosList_fd2_0_c1_c0'>{{item.name}}</text>
              <view class='flex flex-wrap align-center'>
                <view class='flex flex-wrap align-center hosList_fd2_0_c1_c1_c0'>
                  <image class='hosList_fd2_0_c1_c1_c0_c0' mode="aspectFit" :src='STATIC_URL+"500.png"'></image>
                  <text class='hosList_fd2_0_c1_c1_c0_c1'>￥125/月</text>
                </view>
              </view>
              <view class='flex flex-wrap align-center'>
                <image class='hosList_fd2_0_c1_c1_c0_c0' mode="aspectFit" :src='STATIC_URL+"501.png"'></image>
                <text class='hosList_fd2_0_c1_c1_c0_c1'>￥125/月</text>
              </view>
            </view>
          </view>
        </template>
        <fu-empty :pagingListLoadedAll="pagingListLoadedAll" :pagingListNoListData="pagingListNoListData"
          :listDataLength="listDataLength" :isLoadInit="isLoadInit"></fu-empty>
      </view>

      <!---商品列表_商品flex布局结束-->
      <view class="flex benben-position-layout flex flex-wrap align-center hosList_flex_3">
        <view class='flex flex-wrap align-center hosList_fd3_0' @tap="handleJumpDiy" data-type="switchTab"
          :data-url="`/pages/tabBar/shopping/shopping`">
          <image class='hosList_fd3_0_c0' mode="aspectFit" :src='STATIC_URL+"29.png"'></image>
          <benben-message-num class='hosList_fd3_0_c1' :message-num="cartNum.count" size='24' color='#fff'
            background-color='#FE5014'>
          </benben-message-num>
        </view>

      </view>
      <view :style="{height: '152rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction align-stretch benben-flex-layout hosList_flex_4">
        <view class='flex flex-wrap align-center justify-between'>
          <template v-for='(item,key0) in dataList'>
            <view class='flex flex-direction flex-wrap align-stretch hosList_fd4_0_c0' @tap.stop="handleJumpDiy"
              data-type="navigateTo" :data-url="`/?commodity_id=${item.aid}`" :key='key0'>
              <image class='hosList_fd4_0_c0_c0' mode="aspectFill" :src='item.thumb' v-if="commoditype=='1'"></image>
              <image class='hosList_fd4_0_c0_c0' mode="aspectFill" :src='item.thumb' v-if="commoditype=='2'"></image>
              <text class='flex-sub hosList_fd4_0_c0_c1'>{{item.name}}</text>
              <view class='flex flex-direction align-stretch hosList_fd4_0_c0_c2'>
                <view class='flex flex-wrap align-center hosList_fd4_0_c0_c2_c0'>
                  <image class='hosList_fd4_0_c0_c2_c0_c0' mode="aspectFit" :src='STATIC_URL+"500.png"'></image>
                  <text class='hosList_fd4_0_c0_c2_c0_c1'>￥125/月</text>
                </view>
                <view class='flex flex-wrap align-center'>
                  <image class='hosList_fd4_0_c0_c2_c0_c0' mode="aspectFit" :src='STATIC_URL+"501.png"'></image>
                  <text class='hosList_fd4_0_c0_c2_c0_c1'>￥125/月</text>
                </view>
              </view>
              <view class='flex flex-wrap align-center justify-between hosList_fd4_0_c0_c3'>
                <text class='hosList_fd4_0_c0_c3_c0'>尚好家旗舰店</text>
                <view class='flex flex-wrap align-center'>
                  <text class='hosList_fd4_0_c0_c3_c0'>进店</text>
                  <text class='fu-iconfont2  hosList_fd4_0_c0_c3_c1_c1'>&#xe7f2;</text>
                </view>
              </view>
            </view>
          </template>
          <fu-empty :pagingListLoadedAll="pagingListLoadedAll" :pagingListNoListData="pagingListNoListData"
            :listDataLength="listDataLength" :isLoadInit="isLoadInit"></fu-empty>
        </view>
      </view>

      <!---flex布局flex布局结束-->


    </view>
  </view>
</template>
<script>
  import pagingList from '@/common/mixin/paging_list.js';
  import {
    validate
  } from '@/common/utils/validate.js'

  export default {
    components: {},
    mixins: [pagingList],

    data() {
      return {
        "minixPagingListsApi": "",
        "pageingListApiMethod": "",
        "allowOnloadGetList": false,
        "cut": "1",
        "brand_type": [{
          "name": "钙尔奇",
          "value": "1",
          "image": ""
        }, {
          "name": "汤臣倍健",
          "value": "2",
          "image": ""
        }, {
          "name": "哈药",
          "value": "3",
          "image": ""
        }],
        "brand_id": "",
        "price_type": [{
          "name": "0-90",
          "value": "0,90",
          "image": ""
        }, {
          "name": "100-199",
          "value": "100,199",
          "image": ""
        }, {
          "name": "200-299",
          "value": "200,299",
          "image": ""
        }, {
          "name": "300-599",
          "value": "300,599",
          "image": ""
        }, {
          "name": "599元+",
          "value": "599",
          "image": ""
        }],
        "price_id": "",
        "acut": "1",
        "goods_List": [],
        "dataDrandList": [],
        "dataShopList": [],
        "cutId": "1",
        "sort_field": "1",
        "sort_type": "desc",
        "showId": "1",
        "min_price": "",
        "max_price": "",
        "cartNum": {
          "count": ""
        },
        "money": 0,
        "dataList": [],
        "commoditype": "1",
        "keyword": "",
        "cid": ""
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },
      isLogin() {
        return this.$store.state.token == '' ? false : true;
      },
      /**
       * @returns
       * Android       安卓
       * IOS       苹果
       * Web       H5 或 pc
       * Wechat       微信小程序
       * Alipay       支付宝小程序
       * Baidu       百度小程序
       * ByteBounce       抖音小程序
       * 360       360小程序
       * FastApp       快应用
       */
      appSystemIdentification() {
        return this.$store.state.appSystemIdentification
      }
    },
    watch: {},
    onLoad(options) {
      let {
        keyword,
        cid
      } = options
      if (keyword !== undefined) this.keyword = keyword
      if (cid !== undefined) this.cid = cid
      this.getListFunc()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {
      this.getListFunc()
    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //清空关键词
      cleanKeywordFunc() {
        this.keyword = ''
        if (this.showId == '1') {
          this.goodsListFunc()
        } else {
          this.queryShopListFunc()
        }
      },
      //切换商品排序
      switchShopListFunc(type) {
        this.sort_field = type;
        if (this.sort_type == 'desc') {
          this.sort_type = 'asc';
        } else {
          this.sort_type = 'desc';
        }
        this.showId = '1';
        this.goodsListFunc()
      },
      //重置
      getResetFunc() {
        this.brand_id = '';
        this.price.min = '';
        this.price.max = '';
        this.popupShow1679566295078 = false
      },
      //确定
      getQueRenFunc() {
        this.popupShow1679566295078 = false;

      },
      //获取商品列表1
      goodsListFunc() {
        this.minixPagingListsApi = global.apiUrls.post64184ac1cafc3;
        this.pageingListApiMethod = 'get';
        this.allowOnloadGetList = false;
        this.pagingListPostDataContent = {
          keyword: this.keyword,
          order: this.sort_type,
          sort: this.sort_field,
          cid: this.cid,
          business_parameters: 'synthesize',
          max_price: this.max_price,
          brand_id: this.brand_id,
          min_price: this.min_price,
          goods_type: '5'
        }
        this.listData = [];
        this.goods_List = this.listData;
        this.pagingListToggle();

      },
      //综合切换
      switchComprehensiveFunc() {
        this.sort_field = '1';
        this.showId = '1';
        this.goodsListFunc()
      },
      //商品管理-获取品牌列表
      async queryDrandListFunc() {
        //请求方法
        //数据验证

        let datadataDrandList = await this.$api.get(global.apiUrls.post63e36c4963fb8, {

        });

        if (datadataDrandList.data.code != 1) {
          this.$message.info(datadataDrandList.data.msg);
          return
        }
        let infodataDrandList = datadataDrandList.data;
        this.dataDrandList = infodataDrandList.data

      },
      //商品搜索-获取店铺列表
      queryShopListFunc() {
        this.minixPagingListsApi = global.apiUrls.post641e88b843d57;
        this.pageingListApiMethod = 'get';
        this.allowOnloadGetList = false;
        this.pagingListPostDataContent = {
          keyword: this.keyword
        }
        this.listData = [];
        this.dataShopList = this.listData;
        this.pagingListToggle();

      },
      //宫格列表切换
      switchcutFunc(cutId) {
        this.cutId = cutId;
      },
      //切换商品店铺
      switchShopStoreFunc() {
        this.showId = '2';
        this.sort_field = '';
        this.queryShopListFunc()
      },
      //顶部搜索
      topSearchFunc() {
        this.$store.commit('appSearchHistoryAdd', {
          "name": this.keyword
        })
        if (this.showId == '1') {
          this.goodsListFunc()
        } else {
          this.queryShopListFunc()
        }
      },

      //积分商城-积分商品列表
      getListFunc() {
        this.minixPagingListsApi = global.apiUrls.post641457e74fa3e;
        this.pageingListApiMethod = 'get';
        this.allowOnloadGetList = false;
        this.pagingListPostDataContent = {}
        this.listData = [];
        this.dataList = this.listData;
        this.pagingListToggle();

      },
      pagingListPostData() {
        return this.pagingListPostDataContent
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: #F8F8F8;
    background-size: 100% auto;
  }

  .hosList_flex_0 {
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .hosList_fd0_0_c2 {
    width: 30%;
  }

  .hosList_fd0_0_c1_c2 {
    width: 20rpx;
    height: 20rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .hosList_fd0_0_c1_c1 {
    font-size: 28rpx;
    font-weight: 400;
    color: var(--benbenFontColor0);
  }

  .hosList_fd0_0_c1_c0 {
    font-size: 24rpx;
    color: rgba(153, 153, 153, 1);
    margin: 0rpx 14rpx 0rpx 0rpx;
  }

  .hosList_fd0_0_c1 {
    background: #F9F9F9;
    height: 64rpx;
    border-radius: 34rpx 34rpx 34rpx 34rpx;
    padding: 0rpx 24rpx 0rpx 24rpx;
    margin: 0rpx 0rpx 0rpx 32rpx;
  }

  .hosList_fd0_0_c0_c0 {
    font-size: 36rpx;
    font-weight: 500;
    color: #333;
  }

  .hosList_fd0_0 {
    padding: 0rpx 24rpx 0rpx 24rpx;
    line-height: 88rpx;
  }

  .hosList_flex_1 {
    background: #fff;
    width: 750rpx;
    height: 100rpx;
    overflow: hidden;
    z-index: 10;
    top: 87rpx;
    background-size: 100% auto !important;
  }

  .hosList_fd1_0_c3_c0 {
    width: 30rpx;
    height: 28rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .hosList_fd1_0_c3 {
    border-right: 1px solid rgba(237, 237, 237, 1);
    margin: 0rpx 32rpx 0rpx auto;
  }

  .hosList_fd1_0_c2_c0_1 {
    color: var(--benbenFontColor5);
    font-size: 28rpx;
    font-weight: 400;
    line-height: 40rpx;
    margin: 0rpx 10rpx 0rpx 0rpx;
  }

  .hosList_fd1_0_c2 {
    margin: 0rpx 64rpx 0rpx 0rpx;
  }

  .hosList_fd1_0_c1_c1 {
    width: 10rpx;
    height: 18rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .hosList_fd1_0_c1_c0_1 {
    font-size: 28rpx;
    font-weight: 400;
    line-height: 40rpx;
    margin: 0rpx 10rpx 0rpx 0rpx;
    color: var(--benbenFontColor5);
  }

  .hosList_fd1_0_c1_c0 {
    color: var(--benbenFontColor0);
    font-size: 28rpx;
    font-weight: 400;
    line-height: 40rpx;
    margin: 0rpx 10rpx 0rpx 0rpx;
  }

  .hosList_fd1_0_c1 {
    margin: 0rpx 148rpx 0rpx 0rpx;
  }

  .hosList_fd1_0_c0_c0_1 {
    font-size: 28rpx;
    font-weight: 500;
    line-height: 35rpx;
    color: var(--benbenFontColor5);
  }

  .hosList_fd1_0_c0_c0 {
    color: var(--benbenFontColor0);
    font-size: 28rpx;
    font-weight: 500;
    line-height: 35rpx;
  }

  .hosList_fd1_0_c0 {
    margin: 0rpx 149rpx 0rpx 0rpx;
  }

  .hosList_fd1_0 {
    padding: 0rpx 0rpx 0rpx 47rpx;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 40rpx;
  }

  .hosList_flex_2 {
    padding: 0rpx 24rpx 0rpx 24rpx;
  }

  .hosList_fd2_0_c1_c1_c0_c1 {
    color: rgba(217, 50, 32, 1);
    font-weight: 600;
  }

  .hosList_fd2_0_c1_c1_c0_c0 {
    width: 32rpx;
    height: 32rpx;
    margin: 0rpx 10rpx 0rpx 0rpx;
  }

  .hosList_fd2_0_c1_c1_c0 {
    margin: 12rpx 0rpx 12rpx 0rpx;
  }

  .hosList_fd2_0_c1_c0 {
    line-height: 40rpx;
    font-size: 28rpx;
    font-weight: 700;
    color: var(--benbenFontColor0);
    -webkit-line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
  }

  .hosList_fd2_0_c1 {
    margin: 0rpx 0rpx 0rpx 24rpx;
  }

  .hosList_fd2_0_c0 {
    width: 220rpx;
    height: 220rpx;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
  }

  .hosList_fd2_0 {
    border-bottom: 1px solid rgba(238, 238, 238, 1);
    background: #FFFFFF;
    padding: 24rpx 24rpx 24rpx 24rpx;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
    margin: 24rpx 0rpx 0rpx 0rpx;
  }

  .hosList_flex_3 {
    width: 152rpx;
    height: 152rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(450rpx + var(--window-bottom));
    right: 0rpx;
  }

  .hosList_fd3_0_c1 {
    position: absolute;
    top: 22rpx;
    right: 25rpx;
  }

  .hosList_fd3_0_c0 {
    width: 152rpx;
    height: 152rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .hosList_fd3_0 {
    position: relative;
  }

  .hosList_flex_4 {
    padding: 0rpx 24rpx 0rpx 24rpx;
  }

  .hosList_fd4_0_c0_c3_c1_c1 {
    font-size: 22rpx;
    color: var(--benbenFontColor1);
  }

  .hosList_fd4_0_c0_c3_c0 {
    color: var(--benbenFontColor1);
    font-size: 24rpx;
  }

  .hosList_fd4_0_c0_c3 {
    background: rgba(246, 246, 246, 1);
    padding: 6rpx;
    border-radius: 44rpx;
    background-size: 100% auto;
    width: 300rpx;
    margin: 12rpx auto 0rpx auto;
  }

  .hosList_fd4_0_c0_c2_c0_c1 {
    color: rgba(217, 50, 32, 1);
    font-weight: 600;
  }

  .hosList_fd4_0_c0_c2_c0_c0 {
    width: 32rpx;
    height: 32rpx;
    margin: 0rpx 10rpx 0rpx 0rpx;
  }

  .hosList_fd4_0_c0_c2_c0 {
    margin: 12rpx 0rpx 12rpx 0rpx;
  }

  .hosList_fd4_0_c0_c2 {
    margin: 0rpx 20rpx 0rpx 20rpx;
  }

  .hosList_fd4_0_c0_c1 {
    font-size: 28rpx;
    font-weight: 500;
    color: rgba(51, 51, 51, 1);
    margin: 0rpx 20rpx 0rpx 20rpx;
    -webkit-line-clamp: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
  }

  .hosList_fd4_0_c0_c0 {
    width: 346rpx;
    height: 346rpx;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
    margin: 0rpx 0rpx 24rpx 0rpx;
  }

  .hosList_fd4_0_c0 {
    background: #fff;
    background-size: 100% auto !important;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
    padding: 0rpx 0rpx 22rpx 0rpx;
    margin: 0rpx 0rpx 8rpx 0rpx;
    width: 346rpx;
  }
</style>
